import { TableCustom } from '@vh-admin/pro-components';
import { useModel } from '@umijs/max';
import { userCreate, userDel, userEdit, userIndex } from '@/services/sys/user';
import { columnsFn } from './define';
import access from '@/access';
const { checkPermissionAuth } = access();
function Account() {
  const { globalInfo } = useModel('useGlobalModel');

  return (
    <>
      <TableCustom<any>
        request={userIndex}
        columns={globalInfo ? columnsFn(globalInfo.dictionaries) : []}
        headerTitleConfig={{
          create: {
            auth: () => {
              return checkPermissionAuth({ accessId: 24 });
            },
            text: '新增账号',
            modalConfig: {
              modalType: 'Form',
              edit: false,
              config: { width: 'double', title: '新增账号', submitRequest: userCreate },
            },
          },
        }}
        operationConfig={{
          edit: {
            auth: () => {
              return checkPermissionAuth({ accessId: 25 });
            },
            modalConfig: {
              modalType: 'Form',
              edit: true,
              config: { width: 'double', title: '编辑账号', submitRequest: userEdit },
            },
          },
          delete: {
            auth: () => {
              return checkPermissionAuth({ accessId: 26 });
            },
            modalConfig: {
              modalType: 'Delete',
              edit: true,
              config: { title: '删除账号', submitRequest: userDel },
            },
          },
        }}
      />
    </>
  );
}

export default Account;
